#include<cstdio>
int n,a[100005],i,c[100005]; 
long long ans; 
void nxd(int l,int r) 
{ 
    int mid=(l+r)/2,i,j,tmp; 
    if(r>l) 
    { 
        nxd(l,mid); 
        nxd(mid+1,r); 
        tmp=l; 
        for(i=l,j=mid+1;i<=mid&&j<=r;) 
        { 
            if(a[i]>a[j]) 
            { 
                c[tmp++]=a[j++]; 
                ans+=mid-i+1; 
            } 
            else c[tmp++]=a[i++]; 
        } 
        if(i<=mid)
			for(;i<=mid;) 
				c[tmp++]=a[i++]; 
        if(j<=r) 
			for(;j<=r;) 
				c[tmp++]=a[j++]; 
        for(i=l;i<=r;i++) a[i]=c[i]; 
    } 
} 
int main() 
{ 
    scanf("%d",&n); 
    for(i=1;i<=n;i++) 
		scanf("%d",&a[i]); 
    nxd(1,n); 
    printf("%lld",ans); 
}
